/**
 * Copyright (C) 2009-2012, KingHool.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses.
 */
package com.kinghool.smodel;

import java.util.Map;

import org.jdom.DocType;
import org.jdom.Element;

import com.kinghool.smodel.query.Query;

/**
 * Xml structured model define model represented with xml
 * 
 * @Author Allen Deng(dengtailin@gmail.com)
 * 
 */
public interface IXmlModel extends ITreeModel {
	/**
	 * populate model to element
	 */
	public Element populate();
	
	/***
	 * get element of the XmlModel
	 */
	public Element getElement();
	
	/**
	 * refresh model according to element
	 */
	public void refresh() throws Exception;	  
	
	/**
	 * refresh model according to element
	 */
	public void refresh(Element element);	  
	
	/**
	 * get text value(trim) of element
	 */
	public String getText();
	
	/**
	 * set text value of element
	 */
	public void setText(String text);	
	
	/**
	 * get full child text of the root element
	 */
	public String getChildText(String childFullName, Query... queries);
	
	/**
	 * set full child text of the root element
	 */
	public void setChildText(String childFullName, String textValue, Query... queries);
	
	/**
	 * add xml child with textValue as Text and propValPairs as xml attributes
	 */
	public IXmlModel addChild(String childFullName, String textValue, Map<String, ? extends Object> propValPairs);
	/**
	 * add xml child with textValue as Text
	 */
	public IXmlModel addChild(String childFullName, String textValue);
	 
	/**
	 * get namespace uri for the xml element
	 */
	public String getNamespaceUri();
	/**
	 * set namespace uri for the xml element
	 */
	public void setNamespaceUri(String namespaceUri);
	/**
	 * get namespace prefix for the xml element
	 */
	public String getNamespacePrefix();
	/**
	 * set namespace prefix for the xml element
	 */
	public void setNamespacePrefix(String namespacePrefix); 
	/**
	 * get a namespace prefix for the xml element property
	 */
	public Map<String, String> getPropertyNameSpace(String property);
	/**
	 * set a namespace for the xml element property
	 */
	public void setPropertyNameSpace(String property, String prefix, String uri);

	/**
	 * get doc type
	 */
	public DocType getDocType();

	/**
	 * set doc type
	 */
	public void setDocType(DocType docType);
	
	/**
	 * clone
	 */
	public IXmlModel clone() throws CloneNotSupportedException;
}
